package lion.framework.core.anno;

import java.lang.annotation.Annotation;

import lion.dev.lang.Init;
import lion.dev.lang.MapJ;
import lion.framework.core.ApplicationInitializer;

@AnnoProcessor(Initializer.class)
public class InitAnnoProcessor implements IAnnotationProcessor {

	@SuppressWarnings("unchecked")
	@Override
	public void processe(MapJ ctx, Annotation anno) throws Exception {

		Object target = ctx.get(AnnotationProcessorManager.ANNO_CONTEXT_TARGET);
		if (!Init.class.isAssignableFrom((Class<?>) target)) { return; }

		Class<Init> clazz = (Class<Init>) target;

		ApplicationInitializer.registInitializer(clazz.newInstance());
	}
}
